#ifndef BASE_CTNETSERVICE_UDP_H_
#define BASE_CTNETSERVICE_UDP_H_

#include "ct_service.h"
#include "ct_udp_socket.h"

class ctNetServiceUDP:
        public ctService
{
        public:
                virtual ~ctNetServiceUDP() { instance_ = NULL; }

        protected:
                ctNetServiceUDP(const std::string &name)
                        : ctService(name)
                {
                        instance_ = this;
                        service_name_ = name;
                        udp_sock_ = NULL;
                }
                bool init(unsigned short port);
                bool serviceCallBack();
                void final();

                virtual void parse_recv_data(const char *data, const uint32_t cmdlen, const sockaddr_in &addr) { }
                char recv_data_[4096+1];
                virtual bool snd(const char *data, const uint32_t len, const sockaddr_in &addr);

        public:
                ctUDPSocket *udp_sock_;

        private:
                static ctNetServiceUDP *instance_;
                std::string service_name_;
};

#endif //BASE_CTNETSERVICE_UDP_H_

